﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Pointandclick.ScreenManagement
{
    abstract class MenuElement
    {
        string label;
        SpriteFont font;
        Rectangle rectangle;

        //Text that will be displayed on screen
        public string Label { get { return label; } }

        public Rectangle Rectangle { get { return rectangle; } set { rectangle = value; } }

        protected SpriteFont Font { get { return font; } }

        public MenuElement(string label, SpriteFont font)
        {
            this.label = label;
            this.font = font;
        }

        /// <summary>
        /// Queries if the option was clicked on
        /// </summary>
        /// <param name="mouse"></param>
        /// <returns></returns>
        public bool ClickedOn()
        {
            //The oldMouse verification is to avoid dragging the mouse into the rectangle and triggering the action
            if (rectangle.Contains(new Point(Inputs.Mouse.X, Inputs.Mouse.Y))
                && (Inputs.OldMouse.LeftButton == ButtonState.Released) && (Inputs.Mouse.LeftButton == ButtonState.Pressed))
                return true;
            return false;
        }

        public abstract void Draw(SpriteBatch spriteBatch, Vector2 Pos, Color color);
    }
}
